﻿using Keyer.DataBase.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;

namespace Keyer.DataBase.Mapping.LocalDB
{
    public class RoleAppMap : EntityTypeConfiguration<sys_roleapp>
    {
        public RoleAppMap()
        {
            // 表名
            this.ToTable("RoleApp");

            // 主键
            this.HasKey(t => t.id);

            // 属性设置
            this.Property(t => t.id)
                .HasColumnName("roleAppId").HasMaxLength(40);
            this.Property(t => t.appId)
                .HasColumnName("appId")
                .HasMaxLength(40);
            this.Property(t => t.id)
                 .HasColumnName("roleAppId").HasMaxLength(40);


            // 关联设置
            this.HasRequired(t => t.role)
                .WithMany(t => t.roleApps)
                .HasForeignKey(t => t.roleId)
                .WillCascadeOnDelete(false);

            this.HasRequired(t => t.app)
                 .WithMany(t => t.roleApps)
                 .HasForeignKey(t => t.appId)
                 .WillCascadeOnDelete(false);

        }
    }
}
